<?php

/**
*  Implementation of hook_views_data()
*/
function quail_server_views_data() {
  $data['quail_server_webpage']['table']['group'] = t('Accessibility Server');
  $data['quail_server_webpage']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );
  $data['quail_server_webpage']['url'] = array(
    'title' => t('Original URL'),
    'help' => t('The Original URL of the website'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  
  $data['quail_server_website_webpage']['table']['join'] = array(
  	'node' => array(
  		'left_field' => 'nid',
  		'field' => 'webpage_nid',
  	),
  );
  $data['quail_server_website_webpage']['website_nid'] = array(
  	'group' => 'Accessibility Server',
  	'title' => 'Website Nid',
  	'help' => 'The Node ID of the website this page belongs to',
  	'argument' => array(
  		'handler' => 'views_handler_argument_node_nid',
  	),
  );
  $data['quail_server_webpage']['total_pages'] = array(
    'title' => t('Total number of pages'),
    'group' => 'Accessibility Server',
    'help' => t('The total number of pages in a website'),
    'field' => array(
      'handler' => 'views_handler_quail_server_total_pages',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['quail_server_webpage']['total_severe'] = array(
    'title' => t('Total Severe Errors'),
    'group' => 'Accessibility Server',
    'help' => t('The total number of severe errors in a website'),
    'field' => array(
      'handler' => 'views_handler_quail_server_total_severe',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['quail_server_webpage']['total_moderate'] = array(
    'title' => t('Total Moderate Errors'),
    'group' => 'Accessibility Server',
    'help' => t('The total number of moderate errors in a website'),
    'field' => array(
      'handler' => 'views_handler_quail_server_total_moderate',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );  
  $data['quail_server_webpage']['total_suggestion'] = array(
    'title' => t('Total Suggestions'),
    'group' => 'Accessibility Server',
    'help' => t('The total number of suggestions in a website'),
    'field' => array(
      'handler' => 'views_handler_quail_server_total_suggestion',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  return $data;
}

function quail_server_views_handlers() {
	 return array(
    'info' => array(
      'path' => drupal_get_path('module', 'quail_server') .'/includes/views/handlers',
    ),
    'handlers' => array(

      // argument handlers
      'views_handler_quail_server_total_moderate' => array(
        'parent' => 'views_handler_field',
      ),
      'views_handler_quail_server_total_pages' => array(
        'parent' => 'views_handler_field',
      ),
      'views_handler_quail_server_total_suggestion' => array(
        'parent' => 'views_handler_field',
      ), 
      'views_handler_quail_server_total_severe' => array(
        'parent' => 'views_handler_field',
      ),
	)
	);
}